package org.example.code.test2025.three_month;

public class test0320 {

    public static void main(String[] args) {
        int[] coins={1,2,5};
        test0320 test = new test0320();
        System.out.println(test.fun(coins,11));
    }
    public int fun(int[] coins,int amount){
        int[] dp = new int[amount+1];
        for(int i=1;i<=amount;i++){
            dp[i]=Integer.MAX_VALUE;
        }
        dp[0]=0;
        for(int c:coins){
            for(int i=c;i<=amount;i++){
                if(dp[i-c]!=Integer.MAX_VALUE){
                    dp[i]=Math.min(dp[i],dp[i-c]+1);
                }
            }
        }
        return dp[amount]==Integer.MAX_VALUE?-1:dp[amount];
    }
}
